<template>
  <div class="userManagement">
    <div class="searchBox">
      <div class="itemBox">
        <div class="itemTitle">医院信息</div>
        <el-input
          class="itemInput"
          v-model="userMsg"
          placeholder="请输入用户姓名/账号/手机号码"
        />
      </div>
      <div class="itemBox">
        <div class="itemTitle">状态</div>
        <el-select v-model="state" placeholder="请选择" class="itemInput">
          <el-option
            v-for="item in stateOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div class="itemBox">
        <div class="itemTitle">创建人</div>
        <el-input
          class="itemInput"
          v-model="founder"
          placeholder="请输入创建人姓名"
        />
      </div>
      <div class="itemBox">
        <div class="itemTitle">创建时间</div>
        <el-date-picker
          v-model="creationTime"
          class="creationTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :clearable="false"
        />
        <img src="@/assets/images/changeTime.png" alt="" class="timeImg" />
      </div>
      <!--   操作按钮   -->
      <div class="operationBox">
        <div class="resetBox" @click="reset()">重置</div>
        <div class="queryBox" @click="getDatalist()">查询</div>
      </div>
    </div>
    <div class="content">
      <div class="addBox" @click="addUser()">新增</div>
      <div class="tableBox">
        <el-table
          :data="tableData"
          style="width: 100%"
          height="600"
          :header-cell-style="{
            background: '#F7F8FA',
            color: '#203549',
          }"
        >
          <el-table-column type="index" label="序号" align="center">
            <template slot-scope="scope">
              {{
                (pageData.currentPage - 1) * pageData.pageSize +
                scope.$index +
                1
              }}
            </template>
          </el-table-column>
          <el-table-column
            prop="hospitalName"
            label="医院名称"
            align="center"
          />
          <el-table-column prop="headName" label="负责人" align="center" />
          <el-table-column label="性别" align="center">
            <template slot-scope="scope">
              {{ scope.row.headGender == 2 ? '女' : '男' }}
            </template>
          </el-table-column>
          <el-table-column prop="headPhone" label="负责人电话" align="center" />
          <el-table-column
            prop="accountNumber"
            label="医院账号"
            align="center"
          />
          <el-table-column label="状态" align="center">
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.isDisabled"
                active-color="#0CD13A"
                inactive-color="#D3D3D6"
                @change="changeState(scope.row)"
              />
            </template>
          </el-table-column>
          <el-table-column prop="creatorName" label="创建人" align="center" />
          <el-table-column label="创建时间" align="center">
            <template slot-scope="scope">
              {{
                scope.row.createTime ? scope.row.createTime.slice(0, 10) : ''
              }}
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <div class="tableOperation">
                <div @click="handleAccountMsg(scope.row)" class="edit">
                  账号信息
                </div>
                <div @click="queryAccountMsg(scope.row)" class="edit">查看</div>
                <el-dropdown
                  placement="bottom"
                  class="queryMore"
                  trigger="click"
                >
                  <span class="more">…</span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item
                      style="color: #0a73e4; text-align: center"
                      @click.native="handleEdit(scope.row)"
                      >编辑</el-dropdown-item
                    >
                    <el-dropdown-item
                      style="color: #0a73e4; text-align: center"
                      @click.native="modifyPassword(scope.row)"
                      >修改密码</el-dropdown-item
                    >
                    <el-dropdown-item
                      style="color: #ff595a; text-align: center"
                      @click.native="handleDetele(scope.row)"
                      >删除</el-dropdown-item
                    >
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <Pagination @getData="getData" :pageData="pageData" />
    </div>

    <!--  新增/编辑/查看医院  -->
    <el-dialog :visible.sync="dialogVisible" width="600px" class="addDialog">
      <div class="dialogContent">
        <div class="header">新增医院</div>
        <div class="formBox">
          <el-form
            :model="ruleForm"
            hide-required-asterisk
            :rules="rules"
            ref="ruleForm"
            label-width="90px"
            class="demo-ruleForm"
          >
            <el-form-item label="医院名称" prop="hospitalName">
              <el-input
                v-model="ruleForm.hospitalName"
                :disabled="dialogType == 2"
                placeholder="请输入内容"
                maxlength="20"
                show-word-limit
              />
            </el-form-item>
            <el-form-item label="负责人" prop="responsiblePerson">
              <el-input
                v-model="ruleForm.responsiblePerson"
                :disabled="dialogType == 2"
                placeholder="请输入负责人"
              />
            </el-form-item>
            <el-form-item label="性别" prop="gender">
              <el-select
                v-model="ruleForm.gender"
                placeholder="请选择性别"
                :disabled="dialogType == 2"
              >
                <el-option label="男" value="1" />
                <el-option label="女" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="负责人电话" prop="phoneNumber">
              <el-input
                v-model="ruleForm.phoneNumber"
                :disabled="dialogType == 2"
                placeholder="请输入内容"
              />
            </el-form-item>
            <el-form-item label="医院账号" prop="HospitalNumber">
              <el-input
                v-model="ruleForm.HospitalNumber"
                :disabled="dialogType == 2"
                placeholder="请输入内容"
                maxlength="20"
                show-word-limit
              />
            </el-form-item>
            <el-form-item label="医院地址" prop="address">
              <el-cascader
                v-model="ruleForm.address"
                :disabled="dialogType == 2"
                :options="options"
                placeholder="请选择"
                :props="{ expandTrigger: 'hover' }"
                class="input"
                @change="regionChange"
              />
            </el-form-item>
            <el-form-item label="详细地址" prop="sureAddress">
              <el-input
                v-model="ruleForm.sureAddress"
                :disabled="dialogType == 2"
                placeholder="请输入内容"
              />
            </el-form-item>
            <el-form-item label="医院标志">
              <input
                @change="uploadFileChange"
                type="file"
                ref="evfile"
                class="imgBox"
                style="display: none"
              />
              <div class="imgBox" v-if="!logoUrl" @click="uploadPic">
                <img src="@/assets/images/upload.png" alt="" class="logo" />
              </div>
              <div class="imgBoxUpload" v-if="logoUrl">
                <img :src="logoUrl" alt="" class="logo" />
                <div class="mode" v-if="dialogType != 2" @click="logoUrl = ''">
                  <i class="el-icon-delete iconDel"></i>
                </div>
              </div>
            </el-form-item>
          </el-form>
        </div>
        <div class="hr"></div>
      </div>
      <span slot="footer" class="dialog-footer" v-if="dialogType != 2">
        <el-button @click="resetForm('ruleForm')">取 消</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!--  修改密码  -->
    <el-dialog
      :visible.sync="dialogModifyPassword"
      width="600px"
      class="addDialog"
    >
      <div class="dialogContent">
        <div class="header">修改密码</div>
        <div class="formBox">
          <el-form
            :model="modifyPasswordRuleForm"
            hide-required-asterisk
            :rules="rulesRuleForm"
            ref="modifyPasswordRuleForm"
            label-width="90px"
            class="demo-ruleForm"
          >
            <el-form-item label="密码" prop="password">
              <el-input v-model="modifyPasswordRuleForm.password" />
            </el-form-item>
            <el-form-item label="确认密码" prop="surePassword">
              <el-input v-model="modifyPasswordRuleForm.surePassword" />
            </el-form-item>
          </el-form>
        </div>
        <div class="hr"></div>
      </div>
      <span slot="footer" class="dialog-footer" v-if="dialogType != 2">
        <el-button @click="resetModifyForm('modifyPasswordRuleForm')"
          >取 消</el-button
        >
        <el-button
          type="primary"
          @click="submitModifyForm('modifyPasswordRuleForm')"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!--  账号信息  -->
    <el-dialog :visible.sync="dialogAccountMsg" width="600px" class="addDialog">
      <div class="dialogContent">
        <div class="header">账号信息</div>
        <div class="accountMsg">
          <div class="item">
            <div class="itemTitle">医院端链接：</div>
            <div class="itemContent">
              {{ accountMsgForm.link }}
            </div>
          </div>
          <div class="item">
            <div class="itemTitle">登录账号：</div>
            <div>{{ accountMsgForm.userName }}</div>
          </div>
          <div class="item">
            <div class="itemTitle">登录密码：</div>
            <div>{{ accountMsgForm.password }}</div>
          </div>
        </div>
        <div class="hr"></div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="copyAccountMsg"
          >复制账号信息</el-button
        >
        <el-button @click="dialogAccountMsg = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import debounce from '@/utils/js/debounce';
import areaData from '@/utils/js/country-level3-data';
import Pagination from '@/components/Pagination';
import { timeMode } from '@/utils/js/util';
import * as qiniu from 'qiniu-js';
export default {
  name: 'HospitalManagement',
  data() {
    return {
      // 新增医院弹窗
      dialogVisible: false,

      // 0--新增医院  1--编辑医院  2--查看详情
      dialogType: 0,

      // 修改密码弹窗
      dialogModifyPassword: false,
      modifyPasswordRuleForm: { password: '', surePassword: '' },
      rulesRuleForm: {
        password: [
          { validator: this.getValidatorPassword(), trigger: 'blur' },
          {
            min: 8,
            max: 20,
            message:
              '请输入8至20位大小写英文字母、特殊符号、数字其中任意三种的组合',
            trigger: 'blur',
          },
        ],
        surePassword: [
          { validator: this.getValidatorSurePassword(), trigger: 'blur' },
          {
            min: 8,
            max: 20,
            message:
              '请输入8至20位大小写英文字母、特殊符号、数字其中任意三种的组合',
            trigger: 'blur',
          },
        ],
      },

      // 账号信息
      dialogAccountMsg: false,

      // 用户信息
      userMsg: '',

      // 状态
      state: '0',
      stateOptions: [
        {
          value: '0',
          label: '全部',
        },
        {
          value: '1',
          label: '开启',
        },
        {
          value: '2',
          label: '禁用',
        },
      ],

      // 创建人
      founder: '',

      //  创建时间
      creationTime: '',

      tableData: [],

      // 传给分页的数据
      pageData: {
        total: 400,
        pageSize: 10,
        currentPage: 1,
      },

      ruleForm: {
        hospitalName: '',
        responsiblePerson: '',
        phoneNumber: '',
        HospitalNumber: '',
        address: [],
        sureAddress: '',
        gender: '',
      },
      rules: {
        hospitalName: [
          { required: true, message: '请输入医院名称', trigger: 'blur' },
        ],
        gender: [{ required: true, message: '请选择性别', trigger: 'change' }],
        responsiblePerson: [
          { required: true, message: '请输入负责人', trigger: 'blur' },
        ],
        phoneNumber: [
          { validator: this.getValidatorPhoneNumber(), trigger: 'blur' },
        ],
        HospitalNumber: [
          { validator: this.getValidatorUserNumber(), trigger: 'blur' },
        ],
        address: [
          { required: true, message: '请选择医院地址', trigger: 'change' },
        ],
        sureAddress: [
          { required: true, message: '请输入详细地址', trigger: 'blur' },
        ],
      },

      // 省市区
      editorInfo: {},

      options: areaData,

      logoUrl: '',

      accountMsgForm: {
        link: '',
        userName: '',
        password: '',
      },

      qiNiuToken: '',

      //  医院id
      hospitalId: '',

      //  判断图片是否上传成功
      // isUpload: false,
    };
  },
  mounted() {
    this.getDatalist();
  },
  methods: {
    // 获取列表数据
    getDatalist() {
      let startTime = '',
        endTime = '';
      if (this.creationTime) {
        startTime =
          timeMode(this.creationTime[0]).datestr + ' 00:' + '00:' + '00';
        endTime =
          timeMode(this.creationTime[1]).datestr + ' 23:' + '59:' + '59';
      }
      let params = {
        pageSize: this.pageData.pageSize,
        page: this.pageData.currentPage,
        hospitalInfo: this.userMsg,
        isDisabled: this.state == 0 ? '' : this.state - 1,
        creatorName: this.founder,
        startTime,
        endTime,
      };
      this.$http
        .searchHospitalListSystem(params)
        .then(res => {
          let { data } = res;
          data.records.forEach(item => {
            item.isDisabled = item.isDisabled == 0 ? true : false;
          });
          this.tableData = data.records;

          this.pageData = {
            total: data.total,
            pageSize: this.pageData.pageSize,
            currentPage: this.pageData.currentPage,
          };
        })
        .catch(() => {});
    },

    //选择地址改变
    regionChange(value) {
      this.editorInfo.province = value[0];
      this.editorInfo.city = value[1];
      this.editorInfo.country = value[2];
    },

    //选择上传文件
    uploadPic() {
      this.$refs.evfile.click();
      this.getUploadToken();
    },

    //获取七牛云凭证
    getUploadToken() {
      this.$http
        .getUploadTokenSystem()
        .then(res => {
          this.qiNiuToken = res.data.data;
        })
        .catch(() => {});
    },

    //头像上传
    uploadFileChange(evfile) {
      let loading;
      let uptoken = this.qiNiuToken;
      let file = evfile.target.files[0]; //Blob 对象，上传的文件
      let key = new Date().getTime() + file.name; // 上传后文件资源名以设置的 key 为主，如果 key 为 null 或者 undefined，则文件资源名会以 hash 值作为资源名。
      let config = {
        useCdnDomain: true, //表示是否使用 cdn 加速域名，为布尔值，true 表示使用，默认为 false。
        region: qiniu.region.z2, // 根据具体提示修改上传地区,当为 null 或 undefined 时，自动分析上传域名区域
      };
      let putExtra = {
        fname: '', //文件原文件名
        params: {}, //用来放置自定义变量
        mimeType: ['image/png', 'image/jpeg', 'image/jpg'], //用来限制上传文件类型，为 null 时表示不对文件类型限制；限制类型放到数组里： ["image/png", "image/jpeg", "image/gif"]
      };
      let observable = qiniu.upload(file, key, uptoken, putExtra, config);
      observable.subscribe({
        next: () => {
          // 主要用来展示进度
          // console.log(res);
          loading = this.$loading({
            lock: true,
            text: '上传中',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)',
          });
          // if (res.total.percent == 100 && res.total.size > 2000000) {
          //   this.$message.error('上传头像图片不能超过2M，请重新上传');
          //   this.isUpload = false;
          // } else {
          // this.isUpload = true;
          // }
        },
        error: err => {
          console.log(err, 'err----');
          // 失败报错信息
          loading.close();
          this.$message.error(
            '上传头像图片失败，请检查图片格式，仅支持：png、jpeg、jpg，请重新上传'
          );
        },
        complete: result => {
          // 接收成功后返回的信息
          loading.close();
          this.logoUrl = 'http://image.scheartmed.com/' + result.key;
        },
      });
    },

    // 复制账号信息
    copyAccountMsg() {
      let item = this.accountMsgForm;
      let url =
        '医院端链接：' +
        item.link +
        '，' +
        '登录账号：' +
        item.userName +
        '，' +
        '登录密码：' +
        item.password; //拿到想要复制的值
      let copyInput = document.createElement('input'); //创建input元素
      document.body.appendChild(copyInput); //向页面底部追加输入框
      copyInput.setAttribute('value', url); //添加属性，将url赋值给input元素的value属性
      copyInput.select(); //选择input元素
      document.execCommand('Copy'); //执行复制命令
      this.$message.success('账号已复制！'); //弹出提示信息，不同组件可能存在写法不同
      //复制之后再删除元素，否则无法成功赋值
      copyInput.remove(); //删除动态创建的节点
    },

    // 修改密码确定
    submitModifyForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          let params = {
            hospitalId: this.hospitalId,
            password: this.modifyPasswordRuleForm.password,
          };
          this.$http
            .updatePasswordSystem(params)
            .then(res => {
              if (res.code == '0000000000') {
                this.$message({
                  type: 'success',
                  message: '修改密码成功!',
                });
                this.dialogModifyPassword = false;
                this.getDatalist();
                this.resetForm(formName);
              } else {
                this.$message({
                  type: 'error',
                  message: '修改密码失败：' + res.msg,
                });
              }
            })
            .catch(() => {});
        } else {
          return false;
        }
      });
    },

    // 用户新增取消
    resetModifyForm(formName) {
      this.dialogModifyPassword = false;
      this.$refs[formName].resetFields();
    },

    //  重置
    reset() {
      this.userMsg = '';
      this.founder = '';
      this.creationTime = '';
      this.state = '0';
      this.pageData = {
        total: 10,
        pageSize: 10,
        currentPage: 1,
      };
      this.getDatalist();
    },

    // 账号是否禁用
    changeState(val) {
      let params = {
        hospitalId: val.hospitalId,
        isDisabled: val.isDisabled ? 0 : 1,
      };
      if (!val.isDisabled) {
        this.$confirm('此操作将禁用该账号, 是否继续?', '禁用', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            this.$http.updateIsDisabledSystem(params).then(res => {
              if (res.code == '0000000000') {
                this.$message({
                  type: 'success',
                  message: '禁用成功!',
                });
              } else {
                this.$message({
                  type: 'error',
                  message: '禁用失败!',
                });
              }
            });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消禁用',
            });
            val.isDisabled = true;
          });
      } else {
        this.$http
          .updateIsDisabledSystem(params)
          .then(res => {
            if (res.code == '0000000000') {
              this.$message({
                type: 'success',
                message: '开启成功!',
              });
            }
          })
          .catch(() => {});
      }
    },

    // 新增
    addUser() {
      this.dialogType = 0;
      this.dialogVisible = true;
      this.logoUrl = '';
      this.clearRules('ruleForm');
    },

    // 查看
    queryAccountMsg(command) {
      this.dialogType = 2;
      this.dialogVisible = true;
      this.logoUrl = command.logo;
      this.ruleForm.hospitalName = command.hospitalName;
      this.ruleForm.responsiblePerson = command.headName;
      this.ruleForm.gender = command.headGender == 1 ? '男' : '女';
      this.ruleForm.phoneNumber = command.headPhone;
      this.ruleForm.HospitalNumber = command.accountNumber;
      this.ruleForm.sureAddress = command.detailAddress;
      this.ruleForm.address = [command.province, command.city, command.country];
      this.hospitalId = command.hospitalId;
    },

    // 删除
    handleDetele(val) {
      let params = {
        hospitalId: val.hospitalId,
      };
      this.$confirm('此操作将删除该账号, 是否继续?', '删除', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.$http.deleteHospitalSystem(params).then(res => {
            if (res.code == '0000000000') {
              this.$message({
                type: 'success',
                message: '删除成功!',
              });
              this.getDatalist();
            } else {
              this.$message({
                type: 'error',
                message: '该账户下含账号数据或患者数据，无法删除!',
              });
            }
          });
        })
        .catch(() => {});
    },

    // 编辑
    handleEdit(command) {
      this.dialogType = 1;
      this.dialogVisible = true;
      this.clearRules('ruleForm');
      this.logoUrl = command.logo;
      this.ruleForm.hospitalName = command.hospitalName;
      this.ruleForm.responsiblePerson = command.headName;
      this.ruleForm.gender = command.headGender == 1 ? '男' : '女';
      this.ruleForm.phoneNumber = command.headPhone;
      this.ruleForm.HospitalNumber = command.accountNumber;
      this.ruleForm.sureAddress = command.detailAddress;
      this.ruleForm.address = [command.province, command.city, command.country];
      this.hospitalId = command.hospitalId;
    },

    // 修改密码
    modifyPassword(val) {
      this.clearRules('modifyPasswordRuleForm');
      this.dialogModifyPassword = true;
      this.hospitalId = val.hospitalId;
    },

    // 清除校验
    clearRules(ruleName) {
      if (typeof this.$refs[ruleName] !== 'undefined') {
        this.$refs[ruleName].resetFields();
      }
    },

    // 账号信息
    handleAccountMsg(val) {
      let params = {
        hospitalId: val.hospitalId,
      };
      this.$http
        .getAccountInfoSystem(params)
        .then(res => {
          let { code, data } = res;
          if (code == '0000000000') {
            this.dialogAccountMsg = true;
            this.accountMsgForm = {
              link: location.host,
              userName: data.accountNumber,
              password: data.password,
            };
          } else {
            this.$message({
              type: 'error',
              message: '查询账号信息失败！',
            });
            this.dialogAccountMsg = false;
          }
        })
        .catch(() => {});
    },

    // 用户编辑/新增确定
    submitForm: debounce(function (formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if (!this.logoUrl) {
            this.$message({
              type: 'error',
              message: '请上传医院标志!',
            });
          } else {
            let obj = {
              hospitalName: this.ruleForm.hospitalName,
              accountNumber: this.ruleForm.HospitalNumber,
              creatorId: sessionStorage.getItem('accountId'),
              headName: this.ruleForm.responsiblePerson,
              headPhone: this.ruleForm.phoneNumber,
              headGender: this.ruleForm.gender,
              detailAddress: this.ruleForm.sureAddress,
              logo: this.logoUrl,
            };
            if (this.dialogType == 0) {
              let params = { ...obj, ...this.editorInfo };
              this.$http
                .addHospitalSystem(params)
                .then(res => {
                  if (res.code == '0000000000') {
                    this.$message({
                      type: 'success',
                      message: '新增成功!',
                    });
                    this.dialogVisible = false;
                    this.getDatalist();
                  } else {
                    this.$message({
                      type: 'error',
                      message: '新增失败：' + res.msg,
                    });
                  }
                })
                .catch(() => {});
            } else if (this.dialogType == 1) {
              let value = this.ruleForm.address;
              this.editorInfo.province = value[0];
              this.editorInfo.city = value[1];
              this.editorInfo.country = value[2];
              if (
                this.ruleForm.gender == '男' ||
                this.ruleForm.gender == '女'
              ) {
                obj.headGender = this.ruleForm.gender == '男' ? 1 : 2;
              }
              obj.hospitalId = this.hospitalId;
              let params = { ...obj, ...this.editorInfo };
              this.$http
                .editHospitalSystem(params)
                .then(res => {
                  if (res.code == '0000000000') {
                    this.$message({
                      type: 'success',
                      message: '编辑成功!',
                    });
                    this.dialogVisible = false;
                    this.getDatalist();
                  } else {
                    this.$message({
                      type: 'error',
                      message: '编辑失败：' + res.msg,
                    });
                  }
                })
                .catch(() => {});
            }
          }
        } else {
          return false;
        }
      });
    }),

    // 用户新增取消
    resetForm(formName) {
      this.dialogVisible = false;
      this.$refs[formName].resetFields();
    },

    //  分页数据改变
    getData(val) {
      this.pageData = val;
      this.getDatalist();
    },

    // 验证手机号码
    getValidatorPhoneNumber() {
      return (rule, value, callback) => {
        if (this.ruleForm.phoneNumber === '') {
          callback(new Error('手机号码不能为空!'));
        } else {
          let srt = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
          if (!srt.test(this.ruleForm.phoneNumber)) {
            callback(new Error('手机号码不正确！'));
          }
          callback();
        }
      };
    },

    // 校验医院账号
    getValidatorUserNumber() {
      return (rule, value, callback) => {
        if (this.ruleForm.HospitalNumber === '') {
          callback(new Error('医院账号不能为空!'));
        } else {
          let srt = /^[A-Za-z]+$/;
          if (!srt.test(this.ruleForm.HospitalNumber)) {
            callback(new Error('医院账号只允许输入大小写英文字母!'));
          }
          callback();
        }
      };
    },

    // 校验密码
    getValidatorPassword() {
      return (rule, value, callback) => {
        if (this.modifyPasswordRuleForm.password === '') {
          callback(new Error('密码不能为空!'));
        } else {
          let srt =
            /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{8,20}$/;
          if (!srt.test(this.modifyPasswordRuleForm.password)) {
            callback(
              new Error(
                '请输入8至20位大小写英文字母、特殊符号、数字其中任意三种的组合!'
              )
            );
          }
          callback();
        }
      };
    },

    // 校验确认密码
    getValidatorSurePassword() {
      return (rule, value, callback) => {
        if (this.modifyPasswordRuleForm.surePassword === '') {
          callback(new Error('确认密码不能为空!'));
        } else if (this.modifyPasswordRuleForm.password === '') {
          callback(new Error('请先输入密码！'));
        } else if (
          this.modifyPasswordRuleForm.surePassword !==
          this.modifyPasswordRuleForm.password
        ) {
          callback(new Error('两次密码不一致!'));
        } else {
          callback();
        }
      };
    },
  },
  components: {
    Pagination,
  },
};
</script>

<style scoped lang="less">
.userManagement {
  .searchBox {
    height: 64px;
    background: #fff;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    .itemBox {
      display: flex;
      align-items: center;
      margin-right: 32px;
      position: relative;

      .itemTitle {
        font-size: 14px;
        font-weight: 400;
        color: #111111;
        white-space: nowrap;
        text-align: right;
      }
      /deep/ .itemInput {
        margin-left: 8px;

        .el-input__inner {
          width: 240px;
          height: 32px;
        }
        .el-input__icon {
          line-height: 32px;
        }
      }

      /deep/ .creationTime {
        width: 310px;
        height: 32px;
        margin-left: 8px;
        .el-icon-date {
          display: none;
        }
        .el-range-input {
          text-align: left;
        }
        .el-range-separator {
          width: 10%;
          margin-top: -8px;
        }
      }
      .timeImg {
        width: 18px;
        position: absolute;
        right: 8px;
      }
    }
    .operationBox {
      display: flex;
      .resetBox {
        width: 76px;
        height: 32px;
        border-radius: 2px;
        border: 1px solid #dcdfe6;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        font-weight: 400;
        color: #606266;
        cursor: pointer;
        box-sizing: border-box;
      }
      .queryBox {
        width: 76px;
        height: 32px;
        background: #0a73e4;
        border-radius: 2px;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        font-size: 14px;
        font-weight: 400;
        color: #ffffff;
        margin-left: 8px;
      }
    }
  }
  .content {
    background: #fff;
    padding: 16px;
    box-sizing: border-box;
    margin-top: 16px;
    height: 800px;
    position: relative;
    .addBox {
      width: 76px;
      height: 32px;
      background: #0a73e4;
      border-radius: 2px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      font-size: 14px;
      font-weight: 400;
      color: #ffffff;
      margin-bottom: 16px;
    }
    .tableBox {
      /deep/ .el-popover {
        width: 88px !important;
        .btnBox {
          width: 88px !important;
        }
      }
      .tableOperation {
        display: flex;
        .edit {
          font-size: 14px;
          font-weight: 400;
          color: #0a73e4;
          cursor: pointer;
          margin-right: 16px;
        }

        /deep/ .el-popper {
          margin-top: 0;
        }
        .queryMore {
          .more {
            font-size: 14px;
            font-weight: 400;
            color: #0a73e4;
            cursor: pointer;
          }
        }
      }
    }
  }
  /deep/ .addDialog {
    .el-dialog__header,
    .el-dialog__body {
      padding: 0;
    }
    .dialogContent {
      .header {
        height: 54px;
        border-bottom: 1px solid #e9e8eb;
        font-size: 16px;
        font-weight: 500;
        color: #101b25;
        line-height: 54px;
        padding-left: 16px;
        box-sizing: border-box;
      }
      .formBox {
        padding: 24px 83px;
        box-sizing: border-box;
        .el-form {
          .el-form-item__label {
            line-height: 32px;
            height: 32px;
          }
          .el-form-item__content {
            line-height: 32px;
            height: 32px;
          }
          .el-input__inner {
            width: 340px;
            height: 32px;
          }
          .el-form-item {
            margin-bottom: 16px;
          }
          .el-input__icon {
            line-height: 32px;
          }
          .imgBox {
            width: 60px;
            height: 60px;
            background: #ffffff;
            border-radius: 2px;
            border: 1px solid #dcdee0;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            .logo {
              width: 20px;
            }
          }
          .imgBoxUpload {
            width: 60px;
            height: 60px;
            background: #ffffff;
            border-radius: 2px;
            border: 1px solid #dcdee0;
            cursor: pointer;
            position: relative;
            .logo {
              width: 60px;
              height: 60px;
              object-fit: cover;
            }
            .mode {
              width: 60px;
              height: 60px;
              background: rgba(17, 17, 17, 0.6);
              border-radius: 2px;
              position: absolute;
              top: 0;
              display: none;
              text-align: center;
              .iconDel {
                color: #fff;
                line-height: 60px;
              }
            }
          }
          .imgBoxUpload:hover > .mode {
            display: block;
          }
        }
      }
      .accountMsg {
        padding: 24px 40px;
        box-sizing: border-box;
        .item {
          display: flex;
          margin-bottom: 8px;

          font-size: 14px;
          color: #111111;
          .itemTitle {
            width: 100px;
            text-align: right;
            margin-right: 8px;
          }
          .itemContent {
            color: #2c89dc;
          }
        }
      }
      .hr {
        height: 2px;
        background: #e9e8eb;
      }
    }
  }
}
</style>
